﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Ors.RInterface.Engine.PInvoke;

namespace Ors.RInterface.Engine
{
    public class SexpCustomMarshal:ICustomMarshaler
    {
        static SexpCustomMarshal instance = new SexpCustomMarshal();
        public static ICustomMarshaler GetInstance(string up)
        {
            return instance;
        }
        #region ICustomMarshaler Members

        public void CleanUpManagedData(object ManagedObj)
        {
            
        }

        public void CleanUpNativeData(IntPtr pNativeData)
        {
            
        }

        public int GetNativeDataSize()
        {
            return Marshal.SizeOf(typeof(SEXP_HEADER))
                   +
                   Marshal.SizeOf(typeof(CLOSSXP));

        }

        public IntPtr MarshalManagedToNative(object ManagedObj)
        {
            return IntPtr.Zero;
        }

        public object MarshalNativeToManaged(IntPtr pNativeData)
        {
            return pSEXP.FromNative(pNativeData);
        }

        #endregion
    }
}
